//
//  LJHCollectionCell.m
//  HEARME
//
//  Created by 曲政永 on 16/1/21.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "LJHCollectionCell.h"
#import "LJHThreeCollectionViewCell.h"
@interface LJHCollectionCell ()<UICollectionViewDataSource,UICollectionViewDelegate>

@end

@implementation LJHCollectionCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createCell];
    }
    return self;
}

-(void)createCell
{
    
    UICollectionViewFlowLayout *recLayout = [[UICollectionViewFlowLayout alloc]init];
    
    recLayout.itemSize = CGSizeMake(WIDTH/3.7, WIDTH/2.3);
    
    recLayout.sectionInset = UIEdgeInsetsMake(10, 15, 15, 20);
    
    self.recCollectionView = [[LJHBaseCollectionView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, WIDTH/2) collectionViewLayout:recLayout];
    [self.contentView addSubview:self.recCollectionView];
//    self.recCollectionView.backgroundColor = [UIColor whiteColor];
    self.recCollectionView.delegate = self;
    self.recCollectionView.dataSource = self;
    self.recCollectionView.showsHorizontalScrollIndicator = NO;

    [self.recCollectionView registerClass:[LJHThreeCollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
    
    
}

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
    {
        if (self.allPicArray.count!=0) {
        
        LJHChildListModel *model = [self.allPicArray objectAtIndex:indexPath.row];
        [self.picTableCellDelegate JumpToAlbumView:model.albumId :self.myTitle :model.trackId];
        NSLog(@"diandian%@%@%ld",model.albumId,self.myTitle,(long)model.trackId);
        }
        
        if (self.anAllPicArray.count!=0) {
            
            LJHAnchorThreeModel *model = [self.anAllPicArray objectAtIndex:indexPath.row];
            [self.picTableCellDelegate JumpToAlbumMin:model.nickname :model.uid];
//            NSLog(@"diandian%@%@%ld",model.albumId,self.myTitle,(long)model.trackId);
            
        }
        
        
    }
    
    

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 3;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    LJHThreeCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    cell.textModel = [self.allPicArray objectAtIndex:indexPath.row];
    if (self.anAllPicArray.count!=0) {
        cell.threeModel = [_anAllPicArray objectAtIndex:indexPath.row];

    }

    
    return cell;
}
-(void)setAllPicArray:(NSMutableArray *)allPicArray
{
    if (_allPicArray!=allPicArray) {
        [_allPicArray release];
        _allPicArray = [allPicArray retain];
    }
    [self.recCollectionView reloadData];
}

-(void)setAnAllPicArray:(NSMutableArray *)anAllPicArray
{
    if (_anAllPicArray!=anAllPicArray) {
        [_anAllPicArray release];
        _anAllPicArray = [anAllPicArray retain];
    }
    [self.recCollectionView reloadData];
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
